package com.lazar.ke.encrypt;

import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.codec.binary.Base64;

public class EncryptUtils {

    public static void main(String[] args) {

        String pwd = "123456";
        String key = "king";

        //String aespwd = AESUtils.encrypt(pwd,key);
        //System.out.println("aes加密:"+aespwd);
        //System.out.println("aes解密:"+AESUtils.decrypt(aespwd,key));


        //String bcrypwd = BCryptUtil.encrypt(pwd);
        //System.out.println("bcrypt加密:"+bcrypwd);
        //System.out.println("bcrypt验证:"+(BCryptUtil.authenticate(pwd,bcrypwd)?"true":"false"));


        //des有问题
        String despwd = DesUtil.encrypt(pwd,key);
        System.out.println("des加密:"+despwd);
        System.out.println("des解密:"+DesUtil.decrypt(despwd,key));

        //String pbkrypwd = PBKDF2Util.encrypt(pwd,key);
        //System.out.println("pbkrypwd加密:"+pbkrypwd);
        //System.out.println("pbkrypwd验证:"+(PBKDF2Util.authenticate(pwd,pbkrypwd,key)?"true":"false"));

//        System.out.println("md5加密:"+SHAUtil.SHAMD5(pwd));
//        System.out.println("sha1 256加密:"+SHAUtil.SHA256(pwd));
//        System.out.println("sha1 512加密:"+SHAUtil.SHA512(pwd));

    }
}


